<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;

class Workflow extends CrmController
{
    /**
     * WorkflowList
     */
    public function workflowList()
    {
        $menuname = "Workflow";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];
        $this->assign("priv",$priv);
        // 模板输出
        return $this->fetch('workflowList');
    }


    /**
     * 获取工作流列表资料
     * @return [json] [工作流数据]
     */
    public function workflowDataList()
    {
        $page = $_REQUEST["page"];
        $limit = $_REQUEST["limit"];
        //需先判断传值是否为空
        $where = "(1 ";
        $where .= empty($_REQUEST["user"])?"":" AND user = '".$_REQUEST["user"]."'";
        $where .= empty($_REQUEST["leader"])?"":" AND leader = '".$_REQUEST["leader"]."'";
        $where .= empty($_REQUEST["type"])?"":" AND type = '".$_REQUEST["type"]."'";
        $where .= empty($_REQUEST["status"])?"":" AND status = '".$_REQUEST["status"]."'";
        $where .= empty($_REQUEST["cc"])?"":" AND cc like '%".$_REQUEST["cc"]."%'";
        $where .= empty($_REQUEST["start_addtime"])?"":" AND addtime > '".$_REQUEST["start_addtime"]."'";
        $where .= empty($_REQUEST["end_addtime"])?"":" AND addtime < '".$_REQUEST["end_addtime"]."'";
        $where .= " )";

        $arrData = Loader::model('Workflow')->getWorkflowData($where,$page,$limit);
        echo json_encode($arrData);
    }


}